import store from '@/store'

export function authorityHandle(id, authenticity) {
  const authority = store.getters.authority
  // console.log(authority,'0---1')
  if (typeof id === 'object') { // 多id
    return multiple(id, authenticity)
  } else { // 单id
    return authority.includes(id)
  }
}

// 多id
function multiple(ids, authenticity) {
  if (authenticity) {
    return existence(ids)
  } else {
    return nothingness(ids)
  }
}

// 存在
function existence(ids) {
  const authority = store.getters.authority
  const judge = false
  for (let i = 0; i < ids.length; i++) {
    const itemData = ids[i]
    console.log(ids[i],'0--3')
    if (authority.indexOf(itemData) != -1) {
      return true
    }
  }
  return judge
}

// 不存在
function nothingness(ids) {
  const authority = store.getters.authority
  const judge = true
  for (let i = 0; i < ids.length; i++) {
    const itemData = ids[i]
    if (authority.indexOf(itemData) != -1) {
      return false
    }
  }
  return judge
}

/*
该说不说
挺二逼

确实

木错啊
*/
